-
Notifications
You must be signed in to change notification settings - Fork 265
[Torch FX] Compress PT2E Support #3663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
…match in signatures in prepare_pt2e.
src/nncf/experimental/quantization/algorithms/weight_compression/algorithm.py
Outdated
Show resolved
Hide resolved
src/nncf/experimental/torch/fx/quantization/quantizer/__init__.py
Outdated
Show resolved
Hide resolved
daniil-lyakhov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I see the PR with OpenVINOQuantizer?
src/nncf/experimental/quantization/algorithms/weight_compression/algorithm.py
Outdated
Show resolved
Hide resolved
src/nncf/experimental/quantization/algorithms/weight_compression/algorithm.py
Outdated
Show resolved
Hide resolved
| ) -> torch.fx.GraphModule: | ||
| self._quantizer = quantizer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typehints an docstring are missing
src/nncf/quantization/algorithms/weight_compression/algorithm.py
Outdated
Show resolved
Hide resolved
src/nncf/experimental/quantization/algorithms/weight_compression/algorithm.py
Outdated
Show resolved
Hide resolved
src/nncf/experimental/torch/fx/quantization/quantizer/openvino_adapter.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Daniil Lyakhov <[email protected]>
nikita-savelyevv
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huge work, thanks @anzr299!
Mostly minor comments from my side. Overall the updated approach in src/nncf/quantization/algorithms/weight_compression/algorithm.py looks good in my opinion and does not change the logic of the algorithm.
The only significant difference I noticed is that ratio_defining_params are initialized with primary_config from the start, and then some of the parameters are converted back to backup precision after mixed precision algorithm. Before, it was the other way around. It looks a bit cumbersome during mixed precision assignment, but allows to avoid passing group_size_values which is an improvement compared to the previous approach.
src/nncf/quantization/algorithms/weight_compression/algorithm.py
Outdated
Show resolved
Hide resolved
src/nncf/quantization/algorithms/weight_compression/algorithm.py
Outdated
Show resolved
Hide resolved
src/nncf/quantization/algorithms/weight_compression/algorithm.py
Outdated
Show resolved
Hide resolved
| quantizer_builder: Callable[..., OpenVINOQuantizer], | ||
| model_case: ModelCase, | ||
| quantizer_params, | ||
| pt2e_params, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that in this and some other cases below, pt2e_params argument is not used. Is this on purpose? Won't this result in unnecessary duplication of tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially left it there since all tests had a common fixture with TEST_MODELS. I have modified it now though, to use a different list to get arguments for test cases where pt2e_params is not required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please correct me if I'm wrong, but with TEST_MODELS_NO_PT2E defined as [(m, qparams) for m, qparams, _ in TEST_MODELS], it will still contain repeating entities
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes you're right 🤦
it wasnt visible with current cases since there is only 1 element in the pt2e list.
Done
Co-authored-by: Nikita Savelyev <[email protected]>
…e apply_parameters method
src/nncf/quantization/algorithms/weight_compression/algorithm.py
Outdated
Show resolved
Hide resolved
ljaljushkin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome feature!
| model, graph, statistic_points, dataset, ratio_defining_params, all_weight_params | ||
| ) | ||
| # Apply Mixed precision algorithm to ratio defining parameters | ||
| self._algo._apply_mixed_precision(ratio_defining_params, model, graph, statistic_points) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really minor and not blocking. I'd remove underscore in the name, since methods are used externally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes great point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Changes
Introduced a new API to offer weights compression algorithm for quantizers defined in torch.ao.
Currently only supports OpenVINO Quantizer.
Reason for changes
To support Quantizers defined in torch ao.
Related tickets
169342